import React from 'react';
import { WeaTools, WeaAuth, WeaTab, WeaDialog, WeaLocaleProvider } from 'ecCom';
import { observer } from 'mobx-react';
import { WeaTableNew } from 'comsMobx';
import { Button } from 'antd';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
const { SELECT } = WeaTools.types;

@observer
export default class NewTaskDialog extends React.Component {
    render() {
        const shareCondition = [{
            colSpan: 2,
            conditionType: SELECT,
            domkey: ['shareType'],
            fieldcol: 18,
            label: getLabel('505961', '共享类型'),
            labelcol: 6,
            viewAttr: 2,
            className: "edc-share-type-select",
            options: [{
                key: '1',
                showname: getLabel('509237','人员'),
                selected: true
            }, {
                key: '5',
                showname: getLabel('505963', '所有人'),
            }, {
                key: '2',
                showname: getLabel('505976', '分部'),
            }, {
                key: '3',
                showname: getLabel('505977', '部门'),
            }, {
                key: "6",
                selected: false,
                showname: getLabel('509248','岗位'),
            }, {
                key: "4",
                selected: false,
                showname: getLabel('509249','角色'),
            }, {
                key: "7",
                selected: false,
                showname: getLabel('24002','群组'),
            }]
        }, {
            1: [[{
                browserConditionParam: {
                    completeParams: {},
                    conditionDataParams: {},
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: true,
                    idSeparator: ",",
                    isAutoComplete: 1,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "17",
                    viewAttr: 3,
                    title: getLabel('505966', '选择人员')
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["content"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505966', '选择人员'),
                labelcol: 6,
                viewAttr: 3,
            }], [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            2: [[{
                browserConditionParam: {
                    completeParams: {},
                    conditionDataParams: {},
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: true,
                    idSeparator: ",",
                    isAutoComplete: 1,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "194",
                    viewAttr: 3,
                    title: getLabel('505970', '选择分部'),
                    icon: "icon-coms-hrm",
                    iconBgcolor: "#217346",
                    linkUrl: "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=subcompany&id=",
                    tabs: [{
                        "key": "2",
                        "name": getLabel('505968', '组织结构'),
                        "dataURL": null,
                        "dataParams": null,
                        "isSearch": false,
                        "showOrder": 0,
                        "selected": false
                    }, {
                        "key": "1",
                        "name": getLabel('505969', '按列表'),
                        "dataURL": null,
                        "dataParams": {
                            "list": "1"
                        },
                        "isSearch": true,
                        "showOrder": 0,
                        "selected": false
                    }],
                    "isMultCheckbox": false,
                    "hasBorder": false,
                    "showCheckStrictly": true,
                    "checkStrictly": true,
                    "hideVirtualOrg": false,
                    "expandfirstnode": false,
                    "asynLoadAll": false,
                    "defaultExpandedLevel": 0,
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["content"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505970', '选择分部'),
                labelcol: 6,
                viewAttr: 3,
            }, {
                "colSpan": 2,
                "conditionType": "CHECKBOX",
                "domkey": [
                    "includesub"
                ],
                "fieldcol": 18,
                "isQuickSearch": false,
                "label": getLabel('505971', '含下级'),
                "labelcol": 6,
                "viewAttr": 2
            }], [{
                colSpan: 2,
                conditionType: "INPUT_INTERVAL",
                domkey: ["sec1", "sec2"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('509258','安全级别'),
                labelcol: 6,
                value: [0, ''],
                viewAttr: 3,
                needDefaultValue:false
            }], [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            3: [[{
                browserConditionParam: {
                    completeParams: {},
                    conditionDataParams: {},
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: true,
                    idSeparator: ",",
                    isAutoComplete: 1,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "57",
                    viewAttr: 3,
                    title: getLabel('505972', '选择部门'),
                    icon: "icon-coms-hrm",
                    iconBgcolor: "#217346",
                    linkUrl: "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=department&id=",
                    tabs: [{
                        "key": "2",
                        "name": getLabel('505968', '组织结构'),
                        "dataURL": null,
                        "dataParams": null,
                        "isSearch": false,
                        "showOrder": 0,
                        "selected": false
                    }, {
                        "key": "1",
                        "name": getLabel('505969', '按列表'),
                        "dataURL": null,
                        "dataParams": {
                            "list": "1"
                        },
                        "isSearch": true,
                        "showOrder": 0,
                        "selected": false
                    }],
                    hasBorder: false,
                    showCheckStrictly: true,
                    checkStrictly: true,
                    hideVirtualOrg: false,
                    expandfirstnode: false,
                    asynLoadAll: false,
                    defaultExpandedLevel: 0,
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["content"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505972', '选择部门'),
                labelcol: 6,
                viewAttr: 3,
        
            }, {
                "colSpan": 2,
                "conditionType": "CHECKBOX",
                "domkey": [
                    "includesub"
                ],
                "fieldcol": 18,
                "isQuickSearch": false,
                "label": getLabel('505971', '含下级'),
                "labelcol": 6,
                "viewAttr": 2
            }], [{
                colSpan: 2,
                conditionType: "INPUT_INTERVAL",
                domkey: ["sec1", "sec2"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('509258', '安全级别'),
                labelcol: 6,
                value: [0,''],
                viewAttr: 3,
                needDefaultValue:false
            }], [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            4: [[{
                browserConditionParam: {
                    completeParams: {},
                    conditionDataParams: {},
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: true,
                    idSeparator: ",",
                    isAutoComplete: 1,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "65",
                    viewAttr: 3,
                    title: getLabel('505973', '选择角色')
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["content"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505973', '选择角色'),
                labelcol: 6,
                viewAttr: 3,
            }], [{
                colSpan: 2,
                conditionType: "SELECT",
                domkey: ["rolelevel"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505974', '级别'),
                labelcol: 6,
                viewAttr: 2,
                options: [{
                    key: '0',
                    showname: getLabel('505977', '部门'),
                    selected: true
                }, {
                    key: '1',
                    showname: getLabel('505976', '分部'),
                }, {
                    key: '2',
                    showname: getLabel('505975', '总部'),
                }]
            }], [{
                colSpan: 2,
                conditionType: "INPUT_INTERVAL",
                domkey: ["sec1", "sec2"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('509258', '安全级别'),
                labelcol: 6,
                value: [0,''],
                viewAttr: 3,
                needDefaultValue:false
            }], [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            5: [[{
                colSpan: 2,
                conditionType: "INPUT_INTERVAL",
                domkey: ["sec1", "sec2"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('509258', '安全级别'),
                labelcol: 6,
                value: [0,''],
                viewAttr: 3,
                needDefaultValue:false
            }], [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            6: [[{
                browserConditionParam: {
                    completeParams: {},
                    conditionDataParams: {},
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: true,
                    idSeparator: ",",
                    isAutoComplete: 1,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "278",
                    viewAttr: 3,
                    title: getLabel('505978', '选择岗位')
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["content"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505978', '选择岗位'),
                labelcol: 6,
                viewAttr: 3,
            }], [{
                colSpan: 2,
                conditionType: "SELECT_LINKAGE",
                domkey: ["joblevel"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505979', '岗位级别'),
                labelcol: 6,
                viewAttr: 2,
                options: [{
                    key: '1',
                    showname: getLabel('505975', '总部'),
                    selected: true
                }, {
                    key: '2',
                    showname: getLabel('505980', '指定分部'),
                }, {
                    key: '3',
                    showname: getLabel('505981', '指定部门'),
                }],
                "selectLinkageDatas": {
                    "3": {
                        "browserConditionParam": {
                            asynLoadAll: false,
                                "checkStrictly": true,
                                "completeParams": {},
                                "conditionDataParams": {},
                                "dataParams": {},
                                "defaultExpandedLevel": 0,
                                "destDataParams": {},
                                "expandfirstnode": false,
                                "hasAddBtn": false,
                                "hasAdvanceSerach": true,
                                "hasBorder": false,
                                "hideVirtualOrg": false,
                                "icon": "icon-coms-hrm",
                                "iconBgcolor": "#217346",
                                "idSeparator": ",",
                                "isAutoComplete": 1,
                                "isDetail": 0,
                                "isMultCheckbox": false,
                                "isSingle": false,
                                "linkUrl": "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=department&id=",
                                "pageSize": 10,
                                "quickSearchName": "",
                                "replaceDatas": [],
                                "showCheckStrictly": true,
                                "tabs": [{
                                    "isSearch": false,
                                    "key": "2",
                                    "name": getLabel('25332', '组织结构'),
                                    "selected": false,
                                    "showOrder": 0
                                }, {
                                    "dataParams": {
                                        "list": "1"
                                    },
                                    "isSearch": true,
                                    "key": "1",
                                    "name": getLabel('130619', '按列表'),
                                    "selected": false,
                                    "showOrder": 0
                                }],
                                "title": getLabel('505972', '选择部门'),
                                "type": "57",
                                "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "jobdepartment"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": "",
                        "labelcol": 6,
                        "viewAttr": 3
                    },
                    "2": {
                        "browserConditionParam": {
                            "asynLoadAll": false,
                            "checkStrictly": true,
                            "completeParams": {},
                            "conditionDataParams": {},
                            "dataParams": {},
                            "defaultExpandedLevel": 0,
                            "destDataParams": {},
                            "expandfirstnode": false,
                            "hasAddBtn": false,
                            "hasAdvanceSerach": true,
                            "hasBorder": false,
                            "hideVirtualOrg": false,
                            "icon": "icon-coms-hrm",
                            "iconBgcolor": "#217346",
                            "idSeparator": ",",
                            "isAutoComplete": 1,
                            "isDetail": 0,
                            "isMultCheckbox": false,
                            "isSingle": false,
                            "linkUrl": "/spa/hrm/engine.html#/hrmengine/organization?showTree=false&type=subcompany&id=",
                            "pageSize": 10,
                            "quickSearchName": "",
                            "replaceDatas": [],
                            "showCheckStrictly": true,
                            "tabs": [{
                                "isSearch": false,
                                "key": "2",
                                "name": getLabel('25332', '组织结构'),
                                "selected": false,
                                "showOrder": 0
                            }, {
                                "dataParams": {
                                    "list": "1"
                                },
                                "isSearch": true,
                                "key": "1",
                                "name": getLabel('130619', '按列表'),
                                "selected": false,
                                "showOrder": 0
                            }],
                            "title": getLabel('505970', '选择分部'),
                            "type": "194",
                            "viewAttr": 3
                        },
                        "colSpan": 2,
                        "conditionType": "BROWSER",
                        "domkey": [
                            "jobsubcompany"
                        ],
                        "fieldcol": 18,
                        "isQuickSearch": false,
                        "label": "",
                        "labelcol": 6,
                        "viewAttr": 3
                    }
                },
            }], 
            // [{
            // 	colSpan: 2,
            // 	conditionType: "INPUT_INTERVAL",
            // 	domkey: ["sec1", "sec2"],
            // 	fieldcol: 18,
            // 	isQuickSearch: false,
            // 	label: getLabel(683, "安全级别"),
            // 	labelcol: 6,
            // 	value: [0,''],
            // 	viewAttr: 3,
            //needDefaultValue:false
            // }],
             [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]],
            7: [[{
                browserConditionParam: {
                    dataParams: {},
                    destDataParams: {},
                    hasAddBtn: false,
                    hasAdvanceSerach: false,
                    idSeparator: ",",
                    isAutoComplete: 0,
                    isDetail: 0,
                    isMultCheckbox: false,
                    isSingle: false,
                    pageSize: 10,
                    quickSearchName: "",
                    replaceDatas: [],
                    type: "EMChatGroup",
                    viewAttr: 3,
                    title: getLabel('24002', '群组')
                },
                colSpan: 2,
                conditionType: "BROWSER",
                domkey: ["chatGroup"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('24002', '群组'),
                labelcol: 6,
                viewAttr: 3,
            }],
            [{
                olSpan: 2,
                conditionType: "SELECT",
                domkey: ["rightType"],
                fieldcol: 18,
                isQuickSearch: false,
                label: getLabel('505962', '权限'),
                labelcol: 6,
                options: [{ key: "1", selected: true, showname: getLabel('33564', '查看') },{ key: "2", selected: false, showname: getLabel('513430','维护') }],
                viewAttr: 2,
            }]]
        }];

        const { store } = this.props;
        const { shareDialog, shareListVisible, shareListTableStore, shareDeleteDisabled,disableAll } = store;
        if(disableAll) shareCondition[0].options.splice(1,1);
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@tw6zbl`}
                icon={"icon-coms02-Data-center"}
                iconBgcolor="#1a57a0"
                title={getLabel('505958','共享权限')}
                draggable={true}
                style={{ width: document.documentElement.clientWidth * 0.8, height: document.documentElement.clientHeight * 0.8 }}
                hasScroll={true}
                visible={shareListVisible}
                onCancel={store.hideShareList}
            >
                <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@uzy8qv`}
                    // datas={[{ key: 'custom', title: '非默认共享' }]}
                    // keyParam="key"
                    // selectedKey={shareListType}
                    // onChange={store.changeShareListType}
                    buttons={[
                        (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@nxanaw@addShare`} type="primary" onClick={store.addShare} title={getLabel('505959','新增')}>{getLabel('505959','新增')}</Button>),
                        (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@mzkx5r@delete`} title={getLabel(502286,'删除')} onClick={store.deleteShare} disabled={shareDeleteDisabled}>{getLabel(502286,'删除')}</Button>),
                        (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vq12ei@refresh`} title={getLabel('502292','刷新')} onClick={store.reloadTable}>{getLabel('502292','刷新')}</Button>)
                    ]}
                />
                <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@9tkjex`} comsWeaTableStore={shareListTableStore} register_table={store.reloadTable} needScroll={true} hasOrder={true} uniqueId={true} />
                <WeaAuth ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@krocqj`}
                    icon={"icon-coms02-Data-center"}
                    iconBgcolor="#1a57a0"
                    style={{ height: 'auto' }}
                    conditions={shareCondition}
                    {...shareDialog}
                    modalClassName="edc-app-share-dialog"
                />
            </WeaDialog>
        )
    }
}